# -*- coding:utf-8 -*-

class Student(object):
    def __init__(self, id, name, age, gender):
        self.id = id
        self.name = name
        self.age = age
        self.gender = gender

    def __str__(self):
        return f"学员的id是：{self.id}\n学员的名字是：{self.name}\n学员的年龄是：{self.age}\n学员的性别是：{self.gender}"


class Manger(object):
    def __init__(self):
        self.msg_list = []  # 定义类属性列表存放信息

    def run(self):
        while True:
            # 打印学生管理系统界面
            self.show_mean()
            # 输入数字，选择对应功能
            number = int(input("请输入对应的数字选择功能:"))
            if number == 1:
                self.add_student()
            elif number == 2:
                self.del_student()
            elif number == 3:
                self.update_student()
            elif number == 4:
                self.find_student()
            elif number == 5:
                self.save_student()
            elif number == 6:
                print("欢迎下次使用, 拜拜")
                break
            else:
                print("请输入正确的数字")

    def show_mean(self):
        print("=======欢迎进入学生管理系统，请选择你要实现的功能=======")
        print("\t\t 🍁🍁🍁🍁🍁|1、增加学生信息|🍁🍁🍁🍁🍁")
        print("\t\t 🍁🍁🍁🍁🍁|2、删除学生信息|🍁🍁🍁🍁🍁")
        print("\t\t 🍁🍁🍁🍁🍁|3、修改学生信息|🍁🍁🍁🍁🍁")
        print("\t\t 🍁🍁🍁🍁🍁|4、查找学生信息|🍁🍁🍁🍁🍁")
        print("\t\t 🍁🍁🍁🍁🍁|5、显示学生信息|🍁🍁🍁🍁🍁")
        print("\t\t 🍁🍁🍁🍁🍁|6、保存学生信息|🍁🍁🍁🍁🍁")

    def add_student(self):
        while True:
            id = int(input("请输入学员id: "))
            for data in self.msg_list:
                if data.id == id:
                    print(f"id是{id}的学员已存在，请重新输入")
                    return self.add_student()
            name = input("请输入学员名字：")
            age = input("请输入学员的年龄：")
            gender = input("请输入学员的性别：")
            s_msg = Student(id, name, age, gender)
            self.msg_list.append(s_msg)
            print(self.msg_list)
            print(s_msg)
            func1 = int(input("是否继续添加学员信息：(1.继续添加  2.退出)："))
            if func1 == 2:
                break

    def del_student(self):
        while True:
            student_name = input("请输入需要删除学员的名字：")
            for data in self.msg_list:
                if student_name == data.name:
                    self.msg_list.remove(data)
                    print(f"{student_name}, 删除成功")
                    break
            else:
                print("当前学员不存在")
            func2 = int(input("是否继续删除学员: (1.继续添加  2.退出): "))
            if func2 == 2:
                break

    def update_student(self):
        while True:
            student.id = int(input("请输入需要修改学员的id："))
            for data in self.msg_list:
                if data.id == student.id:
                    data.id = int(input("请输入新的id: "))
                    data.name = input("请输入新的id: ")
                    data.age = input("请输入新的id: ")
                    data.gender = input("请输入新的id: ")
                    print(f"id是{student.id}的学员信息 ---- "
                          f"\n成功修改为：\nid:{data.id}\n名字：{data.name}\n"
                          f"年龄：{data.age}\n性别：{data.gender}")
                    break
            else:
                print("当前学员不存在")
            func3 = int(input("是否继续修改信息: (1.继续修改  2.退出): "))
            if func3 == 2:
                break

    def find_student(self):
        pass

    def save_student(self):
        pass


if __name__ == '__main__':
    student = Manger()
    student.run()
